package com.fei.controller;

import com.fei.pojo.User;
import com.fei.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    @Qualifier("UserServiceImpl")
private UserService userService;
    @RequestMapping("/toadd")
    public String toadd() {
        System.out.println("load");
        return "index";
    }

    @RequestMapping("/add")
    public String addUser(User user) {
        userService.addUser(user);
        System.out.println("添加成功");
        return "index";
    }
@RequestMapping("/main")
    public String load(int account,String password){
        User user = userService.queryUserByAccount(account);
        if(account==user.getAccount()&&password.equals(user.getPassword())){
            return "main";
        }
        else
            return "error";
    }
}
